﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JY.Wpf.Core.Events;

namespace JY.Wpf.Core.ViewModelBases
{
    /// <summary>
    /// 分页接口
    /// </summary>
    public interface IPage<T>
    {
        #region # 属性

        /// <summary>
        /// 页面数据条数
        /// </summary> 
        int PageSize { get; set; }

        #region 最大页数——int MaxPageCount

        /// <summary>
        /// 最大页数
        /// </summary>
        int MaxPageCount { get; set; }
        #endregion

        #region 数据总数——int Count
        /// <summary>
        /// 数据总数
        /// </summary>
        int Count { get; set; }
        #endregion
        /// <summary>
        /// 当前第几页
        /// </summary>
        int PageIndex { get; set; }
        /// <summary>
        /// 当前页数据集合
        /// </summary>
         ObservableCollection<T> CurrentPage { get; }
        #endregion

        #region # 方法

        #region # 查询——void Search()

        /// <summary>
        /// 查询
        /// </summary>
        void Search();
        #endregion

        #region # 翻页——void PageUpdated()
        /// <summary>
        /// 翻页
        /// </summary>
        void PageUpdated();
        #endregion

        #region # 翻页——void PageUpdatedAsync(int index)
        /// <summary>
        /// 翻页
        /// </summary>
        /// <param name="index">页号</param>
        void PageUpdatedAsync(int index);
        #endregion

        #region # 加载页数据——Task<IEnumerable<T>> LoadPageAsync(int index, out int maxPageCount)
        /// <summary>
        /// 加载页数据
        /// </summary>
        /// <param name="index">页号</param>
        /// <returns></returns>
        Task<KeyValuePair<IEnumerable<T>, int>> LoadPageAsync(int index);
        #endregion
        #endregion
    }
}
